package ch.app.controller.switchdemo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

/**
 * @author Yin Yong Gang
 *         Date:
 *         Description:
 */

//@RestController
@Controller
public class SwitchController {

    @RequestMapping("/hi")
    public String findAll() {
        System.out.println("----hi----");

        String key = buildHomePageKeyBy(100l, "home_page_freight_data_%d");
        System.out.println("----hi----" + key);
        return "hello";
    }

    @RequestMapping("/hii")
    public ModelAndView load() {
        ModelAndView mv = new ModelAndView();
        mv.setViewName("hello");
        mv.addObject("key", "backend return");
        System.out.println("----hii----");
        return mv;
    }



    private String buildHomePageKeyBy(Long userId, String key) {
        return String.format(key, userId);
    }
}
